
let equipmentDao  = require('../model/backend/equipment')

//验证客户端请求头部信息
module.exports = async function(req, res, next) {
    let reqPath = req.path;
    let isClient= reqPath.indexOf('client');
     if(isClient>0){
        if (req.headers.authorization) {
         let mac = req.headers.authorization;
         let valicationSocketequipmnet  = await equipmentDao.valicationSocketequipmnet(mac);
         if(valicationSocketequipmnet.length==0){  //验证此设备是否存在
            return await res.json({status:401,msg:"非法设备请求！"})
        }

     }
     else{
         return await res.json({status:401,msg:"非法设备请求！"})
     }
    }
    next();
}
